package cn.btks.resultintegration.achievements.service.impl;

import cn.btks.resultintegration.achievements.pojo.AchievementsType;
import cn.btks.resultintegration.achievements.repository.AchievementsTypeRepository;
import cn.btks.resultintegration.achievements.service.AchievementsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author lijun
 * @Date 2020/12/16 16:01
 */
@Service
public class AchievementsTypeServiceImpl implements AchievementsTypeService {

    @Autowired
    AchievementsTypeRepository achievementsTypeRepository;

    @Override
    public List<AchievementsType> findAll() {
        return achievementsTypeRepository.findAll();
    }

    @Override
    public AchievementsType findById(Long id) {
        Optional<AchievementsType> optional = achievementsTypeRepository.findById(id);
        if(optional.isPresent()){
            return optional.get();
        }
        return null;
    }

    @Override
    public AchievementsType findByCode(String code) {
        return achievementsTypeRepository.findByCode(code);
    }
}
